<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".parent").children().hide();
	$(".parent").addClass("pointer").toggle(
		function(){$(this).children().show();
		},function(){$(this).children().hide();}
	);
	var checked = new Array();
	var checked_val = new Array();
	$(".dimension input[type='checkbox']").change(function(){
		var fieldname = $(this).parent().text();
		var value = $(this).val();
		if ($(this).is(":checked"))
		{
			checked_val.push(value);
			checked.push(fieldname);
			$("#dimension label").remove();
			$("#dimension").append('<label>'+checked+'<input type="hidden" name="fieldname" value="'+checked_val+'" /><input type="hidden" name="fieldname_cn" value="'+checked+'" /></label>');
		}
		else
		{
			var pos = $.inArray(fieldname, checked);
			pos++;
			if (pos)
			{
				checked.splice(pos-1, 1);
				checked_val.splice(pos-1, 1);;
			}
			$("#dimension label").remove();
			$("#dimension").append('<label>'+checked+'<input type="hidden" name="fieldname" value="'+checked_val+'" /><input type="hidden" name="fieldname_cn" value="'+checked+'" /></label>');;
		}
	});
});
</script>
<style>
.pointer {cursor: pointer;}
</style>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>发货日期</th>
	<td>
		<input type="text" name="begin_shipped_time" class="datepicker" value="<?=isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : date('Y-m-01', strtotime(date('Y-m-d',CURRENT_TIMESTAMP).' -1 month')) ?>" /> to
		<input type="text" name="end_shipped_time" class="datepicker" value="<?=isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : date('Y-m-t', strtotime(date('Y-m-d',CURRENT_TIMESTAMP).' -1 month')) ?>" />
	</td>
</tr>
<tr>
	<th>网站</th>
	<td><select name="shop_id">
		<option value="">请选择..</option>
		<?foreach ($shop as $s):?>
		<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id']) echo "selected='selected'";?>><?=$s['name']?></option>
		<?endforeach;?>
	</select></td>
</tr>
<tr>
	<th>维度查询</th>
	<td class="dimension">
		<label><input type="checkbox" name="resend_reason" <?if (isset($_GET['resend_reason']) && $_GET['resend_reason'])echo "checked='checked'";?> value="resend_reason" /> 原因</label>
		<label><input type="checkbox" name="shipping_method" <?if (isset($_GET['shipping_method']) && $_GET['shipping_method'])echo "checked='checked'";?> value="shipping_method" /> 邮寄方式</label>
		<label><input type="checkbox" name="country" <?if (isset($_GET['country']) && $_GET['country'])echo "checked='checked'";?> value="country" /> 国家</label>
		<br />
		<span id="dimension">
		<label><?if(isset($_GET['fieldname_cn'])){echo $_GET['fieldname_cn'].'<input type="hidden" name="filedname" value="'.$_GET['fieldname'].'" />';}?></label>
		</span>
	</td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<?if (isset($_GET['is_search']) && isset($_GET['fieldname']) && $_GET['fieldname']):?>
<p><big>发货总单数：<?=$all_count?></big></p>
<p><big>重发单数：<?=$resend_count?> &nbsp; &nbsp;(<?=($resend_count ? sprintf('%.2f', $resend_count/$all_count*100) : '0.00') . '%'?>)</big></p>
<ul style="list-style: disc; padding: 10px 0px; width: 30%;">
<li><h3><?=str_replace('resend_reason', '原因', str_replace('shipping_method', '邮寄方式',str_replace('country', '国家', str_replace(',', '=>', $_GET['fieldname']))))?></h3></li>
	<?=Helper_BSS_Normal::getResendHtml($result)?>
</ul>
<?endif;?>
<?php $this->_endblock();?>